home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / vb3 / pro4 / settime.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-09-19  |  20.1 KB  |  722 lines

  1. VERSION 2.00
  2. Begin Form SetTimeForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Set Time"
  6.    ClientHeight    =   1320
  7.    ClientLeft      =   2145
  8.    ClientTop       =   2520
  9.    ClientWidth     =   3555
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   1755
  13.    Left            =   2070
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   1320
  18.    ScaleWidth      =   3555
  19.    Top             =   2160
  20.    Width           =   3705
  21.    Begin SSCommand Command3D1 
  22.       Height          =   465
  23.       Left            =   165
  24.       Picture         =   SETTIME.FRX:0000
  25.       TabIndex        =   18
  26.       Top             =   720
  27.       Width           =   540
  28.    End
  29.    Begin CommandButton Command1 
  30.       Cancel          =   -1  'True
  31.       Caption         =   "Cancel"
  32.       Height          =   360
  33.       Index           =   1
  34.       Left            =   2265
  35.       TabIndex        =   20
  36.       Top             =   765
  37.       Width           =   1155
  38.    End
  39.    Begin CommandButton Command1 
  40.       Caption         =   "Set"
  41.       Default         =   -1  'True
  42.       Height          =   360
  43.       Index           =   0
  44.       Left            =   885
  45.       TabIndex        =   19
  46.       Top             =   765
  47.       Width           =   1155
  48.    End
  49.    Begin PictureBox SpinButton 
  50.       AutoSize        =   -1  'True
  51.       BackColor       =   &H00C0C0C0&
  52.       Height          =   360
  53.       Index           =   1
  54.       Left            =   3255
  55.       ScaleHeight     =   330
  56.       ScaleWidth      =   135
  57.       TabIndex        =   17
  58.       TabStop         =   0   'False
  59.       Top             =   240
  60.       Width           =   165
  61.    End
  62.    Begin SSFrame Frame3D1 
  63.       ForeColor       =   &H00000000&
  64.       Height          =   444
  65.       Index           =   1
  66.       Left            =   1830
  67.       TabIndex        =   11
  68.       Top             =   156
  69.       Width           =   1395
  70.       Begin TextBox tYear 
  71.          BackColor       =   &H00C0C0C0&
  72.          BorderStyle     =   0  'None
  73.          Height          =   225
  74.          Left            =   780
  75.          MaxLength       =   4
  76.          TabIndex        =   14
  77.          Tag             =   "y"
  78.          Text            =   "1955"
  79.          Top             =   150
  80.          Width           =   480
  81.       End
  82.       Begin TextBox tDay 
  83.          BackColor       =   &H00C0C0C0&
  84.          BorderStyle     =   0  'None
  85.          Height          =   225
  86.          Left            =   450
  87.          MaxLength       =   2
  88.          TabIndex        =   13
  89.          Tag             =   "d"
  90.          Text            =   "17"
  91.          Top             =   150
  92.          Width           =   240
  93.       End
  94.       Begin TextBox tMonth 
  95.          Alignment       =   1  'Right Justify
  96.          BackColor       =   &H00C0C0C0&
  97.          BorderStyle     =   0  'None
  98.          Height          =   225
  99.          Left            =   120
  100.          MaxLength       =   2
  101.          TabIndex        =   12
  102.          Tag             =   "n"
  103.          Text            =   "09"
  104.          Top             =   150
  105.          Width           =   240
  106.       End
  107.       Begin Label Label1 
  108.          Alignment       =   2  'Center
  109.          BackColor       =   &H00C0C0C0&
  110.          Caption         =   "/"
  111.          Height          =   225
  112.          Index           =   3
  113.          Left            =   690
  114.          TabIndex        =   16
  115.          Top             =   150
  116.          Width           =   105
  117.       End
  118.       Begin Label Label1 
  119.          Alignment       =   2  'Center
  120.          BackColor       =   &H00C0C0C0&
  121.          Caption         =   "/"
  122.          Height          =   225
  123.          Index           =   2
  124.          Left            =   345
  125.          TabIndex        =   15
  126.          Top             =   150
  127.          Width           =   105
  128.       End
  129.    End
  130.    Begin PictureBox SpinButton 
  131.       AutoSize        =   -1  'True
  132.       BackColor       =   &H00C0C0C0&
  133.       Height          =   360
  134.       Index           =   0
  135.       Left            =   1590
  136.       ScaleHeight     =   330
  137.       ScaleWidth      =   135
  138.       TabIndex        =   7
  139.       TabStop         =   0   'False
  140.       Top             =   240
  141.       Width           =   165
  142.    End
  143.    Begin PictureBox N 
  144.       AutoSize        =   -1  'True
  145.       Height          =   360
  146.       Left            =   2970
  147.       Picture         =   SETTIME.FRX:061A
  148.       ScaleHeight     =   330
  149.       ScaleWidth      =   135
  150.       TabIndex        =   6
  151.       TabStop         =   0   'False
  152.       Top             =   1995
  153.       Visible         =   0   'False
  154.       Width           =   165
  155.    End
  156.    Begin PictureBox U 
  157.       AutoSize        =   -1  'True
  158.       Height          =   360
  159.       Left            =   3180
  160.       Picture         =   SETTIME.FRX:0B5C
  161.       ScaleHeight     =   330
  162.       ScaleWidth      =   135
  163.       TabIndex        =   5
  164.       TabStop         =   0   'False
  165.       Top             =   1995
  166.       Visible         =   0   'False
  167.       Width           =   165
  168.    End
  169.    Begin PictureBox D 
  170.       AutoSize        =   -1  'True
  171.       Height          =   360
  172.       Left            =   3405
  173.       Picture         =   SETTIME.FRX:109E
  174.       ScaleHeight     =   330
  175.       ScaleWidth      =   135
  176.       TabIndex        =   0
  177.       TabStop         =   0   'False
  178.       Top             =   1980
  179.       Visible         =   0   'False
  180.       Width           =   165
  181.    End
  182.    Begin SSFrame Frame3D1 
  183.       ForeColor       =   &H00000000&
  184.       Height          =   444
  185.       Index           =   0
  186.       Left            =   168
  187.       TabIndex        =   8
  188.       Top             =   156
  189.       Width           =   1392
  190.       Begin TextBox tHour 
  191.          Alignment       =   1  'Right Justify
  192.          BackColor       =   &H00C0C0C0&
  193.          BorderStyle     =   0  'None
  194.          Height          =   225
  195.          Left            =   120
  196.          MaxLength       =   2
  197.          MultiLine       =   -1  'True
  198.          TabIndex        =   1
  199.          Tag             =   "h"
  200.          Text            =   "12"
  201.          Top             =   150
  202.          Width           =   240
  203.       End
  204.       Begin TextBox tMinute 
  205.          BackColor       =   &H00C0C0C0&
  206.          BorderStyle     =   0  'None
  207.          Height          =   225
  208.          Left            =   456
  209.          MaxLength       =   2
  210.          TabIndex        =   2
  211.          Tag             =   "m"
  212.          Text            =   "00"
  213.          Top             =   150
  214.          Width           =   240
  215.       End
  216.       Begin TextBox tAMPM 
  217.          BackColor       =   &H00C0C0C0&
  218.          BorderStyle     =   0  'None
  219.          Height          =   225
  220.          Left            =   1020
  221.          TabIndex        =   4
  222.          Tag             =   "a"
  223.          Text            =   "am"
  224.          Top             =   150
  225.          Width           =   285
  226.       End
  227.       Begin TextBox tSecond 
  228.          BackColor       =   &H00C0C0C0&
  229.          BorderStyle     =   0  'None
  230.          Height          =   225
  231.          Left            =   780
  232.          MaxLength       =   2
  233.          TabIndex        =   3
  234.          Tag             =   "s"
  235.          Text            =   "00"
  236.          Top             =   150
  237.          Width           =   240
  238.       End
  239.       Begin Label Label1 
  240.          Alignment       =   2  'Center
  241.          BackColor       =   &H00C0C0C0&
  242.          Caption         =   ":"
  243.          Height          =   225
  244.          Index           =   0
  245.          Left            =   345
  246.          TabIndex        =   10
  247.          Top             =   150
  248.          Width           =   105
  249.       End
  250.       Begin Label Label1 
  251.          Alignment       =   2  'Center
  252.          BackColor       =   &H00C0C0C0&
  253.          Caption         =   ":"
  254.          Height          =   225
  255.          Index           =   1
  256.          Left            =   675
  257.          TabIndex        =   9
  258.          Top             =   150
  259.          Width           =   105
  260.       End
  261.    End
  262. Option Explicit
  263. DefInt A-Z
  264. Dim LastY As Single
  265. Dim Active As String
  266. Dim LastDirection As String
  267. Dim tVal As Integer
  268. ' Jeffrey M. Richter's Spin Button Control from Windows 3: A Developer's Guide
  269. ' Adapted for Visual Basic by Costas Kitsos with Mr. Richter's kind permission
  270. ' Windows API functions used by the Spin Button Control
  271. Declare Function GetTickCount Lib "User" () As Long
  272. Declare Function GetAsyncKeyState Lib "User" (ByVal vKey As Integer) As Integer
  273. Sub Command1_Click (Index As Integer)
  274. If Index = 0 Then
  275.   Time = tHour.Text + ":" + tMinute.Text + ":" + tSecond.Text + UCase$(tAMPM.Text)
  276.   Date = tMonth.Text + "/" + tDay.Text + "/" + tYear.Text
  277.   LastTime = 0
  278.   Unload SetTimeForm
  279. End If
  280. If Index = 1 Then
  281.   LastTime = 0
  282.   Unload SetTimeForm
  283. End If
  284. End Sub
  285. Sub Command3D1_Click ()
  286. AtomicTimeWasSet = False
  287. Atomic.Show 1
  288. Unload Atomic
  289. If AtomicTimeWasSet Then
  290.    Unload SetTimeForm
  291. End If
  292. End Sub
  293. Sub FlipFlopTAMPM ()
  294.          If tAMPM.Text = "am" Then
  295.             tAMPM.Text = "pm"
  296.          Else
  297.             tAMPM.Text = "am"
  298.          End If
  299. End Sub
  300. Sub Form_GotFocus ()
  301.     tHour.SetFocus
  302.     DoEvents
  303. End Sub
  304. Sub Form_Load ()
  305. SetTimeForm.Left = Settings.Left + (Settings.Width / 2) - (SetTimeForm.Width / 2)
  306. SetTimeForm.Top = Settings.Top + (Settings.Height / 2) - (SetTimeForm.Height / 2)
  307. Dim Instant As Double
  308. Dim InitialHeight As Integer
  309.     InitialHeight = SpinButton(0).Height
  310.     SpinButton(0).Picture = N.Picture       'Set to the Normal Spin Button
  311.     SpinButton(0).Top = SpinButton(0).Top + (InitialHeight - SpinButton(0).Height) / 2
  312.     SpinButton(1).Picture = N.Picture       'Set to the Normal Spin Button
  313.     SpinButton(1).Top = SpinButton(1).Top + (InitialHeight - SpinButton(1).Height) / 2
  314.     Instant = Now
  315.     If Hour(Instant) = 0 Then
  316.        tHour.Text = "12"
  317.        tAMPM.Text = "am"
  318.     End If
  319.     If Hour(Instant) >= 1 And Hour(Instant) <= 11 Then
  320.        tHour.Text = Format$(Hour(Instant))
  321.        tAMPM.Text = "am"
  322.     End If
  323.     If Hour(Instant) = 12 Then
  324.        tHour.Text = Format$(Hour(Instant))
  325.        tAMPM.Text = "pm"
  326.     End If
  327.     If Hour(Instant) >= 13 And Hour(Instant) <= 23 Then
  328.        tHour.Text = Format$(Hour(Instant) - 12)
  329.        tAMPM.Text = "pm"
  330.     End If
  331.     tMinute.Text = Format$(Minute(Instant), "00")
  332.     tSecond.Text = Format$(Second(Instant), "00")
  333.     tMonth.Text = Format$(Month(Instant), "00")
  334.     tDay.Text = Format$(Day(Instant), "00")
  335.     tYear.Text = Format$(Year(Instant), "0000")
  336.     'SetTimeFOrm.Show
  337.     'DoEvents
  338. End Sub
  339. Sub MoveDown (c As Control)
  340. Dim CurVal As Integer
  341. CurVal% = Val(c.Text)
  342. Select Case c.Tag
  343.    Case "h"
  344.       If CurVal% = 12 Then
  345.          FlipFlopTAMPM
  346.       End If
  347.       If CurVal% = 1 Then
  348.          c.Text = "12"
  349.       Else
  350.          c.Text = Val(c.Text) - 1
  351.       End If
  352.    Case "m"
  353.       If CurVal% = 0 Then
  354.          c.Text = "59"
  355.       Else
  356.          c.Text = Format$(Val(c.Text) - 1, "00")
  357.       End If
  358.    Case "s"
  359.       If CurVal% = 0 Then
  360.          c.Text = "59"
  361.       Else
  362.          c.Text = Format$(Val(c.Text) - 1, "00")
  363.       End If
  364.    Case "a"
  365.       FlipFlopTAMPM
  366.    Case "n"
  367.       If CurVal% = 1 Then
  368.          c.Text = "12"
  369.       Else
  370.          c.Text = Format$(Val(c.Text) - 1, "00")
  371.       End If
  372.    Case "d"
  373.       If CurVal% = 1 Then
  374.          c.Text = "31"
  375.       Else
  376.          c.Text = Format$(Val(c.Text) - 1, "00")
  377.       End If
  378.    Case "y"
  379.       If CurVal% = 1 Then
  380.          c.Text = "2050"
  381.       Else
  382.          c.Text = Format$(Val(c.Text) - 1, "0000")
  383.       End If
  384. End Select
  385. 'c.Text = Val(c.Text) - 1
  386. End Sub
  387. Sub MoveUp (c As Control)
  388. Dim CurVal As Integer
  389. CurVal% = Val(c.Text)
  390. Select Case c.Tag
  391.    Case "h"
  392.       If CurVal% = 11 Then
  393.          FlipFlopTAMPM
  394.       End If
  395.       If CurVal% = 12 Then
  396.          c.Text = "1"
  397.       Else
  398.          c.Text = Val(c.Text) + 1
  399.       End If
  400.    Case "m"
  401.       If CurVal% = 59 Then
  402.          c.Text = "00"
  403.       Else
  404.          c.Text = Format$(Val(c.Text) + 1, "00")
  405.       End If
  406.    Case "s"
  407.       If CurVal% = 59 Then
  408.          c.Text = "00"
  409.       Else
  410.          c.Text = Format$(Val(c.Text) + 1, "00")
  411.       End If
  412.    Case "a"
  413.       FlipFlopTAMPM
  414.    Case "n"
  415.       If CurVal% = 12 Then
  416.          c.Text = "01"
  417.       Else
  418.          c.Text = Format$(Val(c.Text) + 1, "00")
  419.       End If
  420.    Case "d"
  421.       If CurVal% = 31 Then
  422.          c.Text = "01"
  423.       Else
  424.          c.Text = Format$(Val(c.Text) + 1, "00")
  425.       End If
  426.    Case "y"
  427.       If CurVal% = 2050 Then
  428.          c.Text = "1980"
  429.       Else
  430.          c.Text = Format$(Val(c.Text) + 1, "0000")
  431.       End If
  432. End Select
  433. End Sub
  434. Sub SpinButton_DblClick (Index As Integer)
  435. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  436.    tMonth.SetFocus
  437. End If
  438. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  439.    tHour.SetFocus
  440. End If
  441. If LastDirection$ = "u" Then
  442.    Select Case Active$
  443.      Case "n"
  444.         Call MoveUp(tMonth)
  445.      Case "d"
  446.         Call MoveUp(tDay)
  447.      Case "y"
  448.         Call MoveUp(tYear)
  449.      Case "h"
  450.         Call MoveUp(tHour)
  451.      Case "m"
  452.         Call MoveUp(tMinute)
  453.      Case "s"
  454.         Call MoveUp(tSecond)
  455.      Case "a"
  456.         Call MoveUp(tAMPM)
  457.    End Select
  458.    Select Case Active$
  459.      Case "n"
  460.         Call MoveDown(tMonth)
  461.      Case "d"
  462.         Call MoveDown(tDay)
  463.      Case "y"
  464.         Call MoveDown(tYear)
  465.      Case "h"
  466.         Call MoveDown(tHour)
  467.      Case "m"
  468.         Call MoveDown(tMinute)
  469.      Case "s"
  470.         Call MoveDown(tSecond)
  471.      Case "a"
  472.         Call MoveDown(tAMPM)
  473.    End Select
  474. End If
  475. SpinButton(Index).SetFocus
  476. End Sub
  477. Sub SpinButton_GotFocus (Index As Integer)
  478. If (Index = 1) And (Active$ <> "n") And (Active$ <> "d") And (Active$ <> "y") Then
  479.    tMonth.SetFocus
  480.    Exit Sub
  481. End If
  482. If (Index = 0) And (Active$ <> "h") And (Active$ <> "m") And (Active$ <> "s") And (Active$ <> "a") Then
  483.    tHour.SetFocus
  484.    Exit Sub
  485. End If
  486.    Select Case Active$
  487.      Case "n"
  488.         tMonth.SetFocus
  489.      Case "d"
  490.         tDay.SetFocus
  491.      Case "y"
  492.         tYear.SetFocus
  493.      Case "h"
  494.         tHour.SetFocus
  495.      Case "m"
  496.         tMinute.SetFocus
  497.      Case "s"
  498.         tSecond.SetFocus
  499.      Case "a"
  500.         tAMPM.SetFocus
  501.    End Select
  502. End Sub
  503. Sub SpinButton_MouseDown (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  504. Const VK_LBUTTON = &H1
  505. Const TIME_DELAY = 180      ' Time delay between Spin Button Events
  506. Dim dwEvent As Long
  507. LastY = Y
  508. ' Make sure that the Spin Button Event occurs at least once
  509. dwEvent = GetTickCount() - TIME_DELAY
  510. SpinIt:
  511.    ' Do this while the user holds down the left mouse button
  512.    Do While (GetAsyncKeyState(VK_LBUTTON) And &H8000) = -32768
  513.         ' Break out of the loop if we haven't waited long enough
  514.         If dwEvent + TIME_DELAY > GetTickCount() Then GoTo Break:
  515.         ' If the user wants to increment the counter
  516.         If Y > (SpinButton(Index).Height \ 2) Then
  517.             SpinButton(Index).Picture = d.Picture  ' Set Picture to Up
  518.             If Index = 1 Then
  519.             Select Case Active$
  520.                Case "n"
  521.                    Call MoveDown(tMonth)
  522.                Case "d"
  523.                    Call MoveDown(tDay)
  524.                Case "y"
  525.                    Call MoveDown(tYear)
  526.             End Select
  527.             End If
  528.             If Index = 0 Then
  529.             Select Case Active$
  530.                Case "h"
  531.                    Call MoveDown(tHour)
  532.                Case "s"
  533.                    Call MoveDown(tSecond)
  534.                Case "m"
  535.                    Call MoveDown(tMinute)
  536.                Case "a"
  537.                    Call MoveDown(tAMPM)
  538.             End Select
  539.             End If
  540.             LastDirection$ = "d"
  541.         End If
  542.         ' If the user wants to decrement the counter
  543.         If Y < (SpinButton(Index).Height \ 2) Then
  544.             SpinButton(Index).Picture = u.Picture   ' Set Picture to Down
  545.             If Index = 1 Then
  546.             Select Case Active$
  547.                Case "n"
  548.                    Call MoveUp(tMonth)
  549.                Case "d"
  550.                    Call MoveUp(tDay)
  551.                Case "y"
  552.                    Call MoveUp(tYear)
  553.             End Select
  554.             End If
  555.             If Index = 0 Then
  556.             Select Case Active$
  557.                Case "h"
  558.                    Call MoveUp(tHour)
  559.                Case "s"
  560.                    Call MoveUp(tSecond)
  561.                Case "m"
  562.                    Call MoveUp(tMinute)
  563.                Case "a"
  564.                    Call MoveUp(tAMPM)
  565.             End Select
  566.             End If
  567.             LastDirection$ = "u"
  568.         End If
  569.         ' Save the last time the Spin Button was active
  570.         dwEvent = GetTickCount()
  571.     Loop
  572.     ' Set the Picture to Normal
  573.     SpinButton(Index).Picture = N.Picture
  574.     If Index = 1 Then
  575.     Select Case Active$
  576.        Case "n"
  577.           tMonth.SetFocus
  578.        Case "d"
  579.           tDay.SetFocus
  580.        Case "y"
  581.           tYear.SetFocus
  582.     End Select
  583.     End If
  584.     If Index = 0 Then
  585.     Select Case Active$
  586.        Case "h"
  587.           tHour.SetFocus
  588.        Case "m"
  589.           tMinute.SetFocus
  590.        Case "s"
  591.           tSecond.SetFocus
  592.        Case "a"
  593.           tAMPM.SetFocus
  594.     End Select
  595.     End If
  596.     DoEvents
  597.     Exit Sub
  598. Break:
  599.     GoTo SpinIt:
  600. End Sub
  601. Sub tAMPM_GotFocus ()
  602. tAMPM.SelStart = 0
  603. tAMPM.SelLength = 2
  604. Active$ = "a"
  605. End Sub
  606. Sub tAMPM_KeyPress (KeyAscii As Integer)
  607. If KeyAscii >= 32 Then
  608.    FlipFlopTAMPM
  609.    KeyAscii = 0
  610.    tAMPM.SelStart = 0
  611.    tAMPM.SelLength = 2
  612. End If
  613. End Sub
  614. Sub tAMPM_LostFocus ()
  615. If tAMPM.Text <> "am" And tAMPM.Text <> "pm" Then
  616.    tAMPM.Text = "am"
  617. End If
  618. End Sub
  619. Sub tDay_GotFocus ()
  620. tDay.SelStart = 0
  621. tDay.SelLength = 2
  622. Active$ = "d"
  623. End Sub
  624. Sub tDay_KeyPress (KeyAscii As Integer)
  625. If KeyAscii >= 32 Then
  626.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  627. End If
  628. End Sub
  629. Sub tDay_LostFocus ()
  630. tVal = Val(tDay.Text)
  631. If tVal < 1 Or tVal > 31 Then
  632.    tVal = 1
  633. End If
  634. tDay.Text = Format$(tVal, "00")
  635. End Sub
  636. Sub tHour_GotFocus ()
  637. tHour.SelStart = 0
  638. tHour.SelLength = 2
  639. Active$ = "h"
  640. End Sub
  641. Sub tHour_KeyPress (KeyAscii As Integer)
  642. If KeyAscii >= 32 Then
  643.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  644. End If
  645. End Sub
  646. Sub tHour_LostFocus ()
  647. tVal = Val(tHour.Text)
  648. If tVal < 1 Or tVal > 12 Then
  649.    tVal = 12
  650. End If
  651. tHour.Text = Format$(tVal, "0")
  652. End Sub
  653. Sub tMinute_GotFocus ()
  654. tMinute.SelStart = 0
  655. tMinute.SelLength = 2
  656. Active$ = "m"
  657. End Sub
  658. Sub tMinute_KeyPress (KeyAscii As Integer)
  659. If KeyAscii >= 32 Then
  660.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  661. End If
  662. End Sub
  663. Sub tMinute_LostFocus ()
  664. tVal = Val(tMinute.Text)
  665. If tVal <= 0 Or tVal > 59 Then
  666.    tVal = 0
  667. End If
  668. tMinute.Text = Format$(tVal, "00")
  669. End Sub
  670. Sub tMonth_GotFocus ()
  671. tMonth.SelStart = 0
  672. tMonth.SelLength = 2
  673. Active$ = "n"
  674. End Sub
  675. Sub tMonth_KeyPress (KeyAscii As Integer)
  676. If KeyAscii >= 32 Then
  677.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  678. End If
  679. End Sub
  680. Sub tMonth_LostFocus ()
  681. tVal = Val(tMonth.Text)
  682. If tVal < 1 Or tVal > 12 Then
  683.    tVal = 12
  684. End If
  685. tMonth.Text = Format$(tVal, "00")
  686. End Sub
  687. Sub tSecond_GotFocus ()
  688. tSecond.SelStart = 0
  689. tSecond.SelLength = 2
  690. Active$ = "s"
  691. End Sub
  692. Sub tSecond_KeyPress (KeyAscii As Integer)
  693. If KeyAscii >= 32 Then
  694.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  695. End If
  696. End Sub
  697. Sub tSecond_LostFocus ()
  698. tVal = Val(tSecond.Text)
  699. If tVal <= 0 Or tVal > 59 Then
  700.    tVal = 0
  701. End If
  702. tSecond.Text = Format$(tVal, "00")
  703. End Sub
  704. Sub tYear_GotFocus ()
  705. tYear.SelStart = 0
  706. tYear.SelLength = 4
  707. Active$ = "y"
  708. End Sub
  709. Sub tYear_KeyPress (KeyAscii As Integer)
  710. If KeyAscii >= 32 Then
  711.    If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then KeyAscii = 0
  712. End If
  713. End Sub
  714. Sub tYear_LostFocus ()
  715. tVal = Val(tYear.Text)
  716. If tVal < 100 Then tVal = tVal + 1900
  717. If tVal < 1980 Or tVal > 2050 Then
  718.    tVal = 1980
  719. End If
  720. tYear.Text = Format$(tVal, "0000")
  721. End Sub
  722.